﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sharpCmd.Dialogs.PanelActions
{
    public partial class CopyPrepareForm : Form
    {
        public CopyPrepareForm()
        {
            InitializeComponent();
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            //validate directory
            if (!System.IO.Directory.Exists(tbDirectory.Text))
            {
                MessageBox.Show(string.Format("Directory {0} does not exist!", tbDirectory.Text));
                return;
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }

        public string TargetDirectory
        {
            get { return tbDirectory.Text; }
            set { tbDirectory.Text = value; }
        }

        private void tbDirectory_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                buttonOK_Click(null, null);
        }
    }
}